extends Object


class_name EffectHelper


static func display_float_text(node: Node2D, text: String, setting: LabelSettings) -> void:
    var label: Label = Label.new()
    label.text = text
    label.z_index = 1
    label.label_settings = setting
    label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
    node.call_deferred("add_child", label)

    await label.resized
    var half_size: Vector2 = Vector2(label.size / 2)
    label.global_position = node.global_position - half_size
    label.pivot_offset = half_size

    var tween: Tween = node.get_tree().create_tween()
    tween.set_parallel(true)
    tween.tween_property(label, "position:y", label.position.y - 30, 0.25).set_ease(Tween.EASE_OUT)
    tween.tween_property(label, "position:y", label.position.y, 0.15).set_ease(Tween.EASE_IN).set_delay(0.25)
    tween.tween_property(label, "scale", Vector2.ZERO, 0.2).set_ease(Tween.EASE_IN).set_delay(0.15)
    await tween.finished
    label.queue_free()
